package com.lysj.admin.master.bussiness.company.recharge.domain;

import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.lysj.admin.master.bussiness.company.CompanyEntity;
import com.lysj.admin.master.common.enumeration.EnumInterface;
import com.lysj.admin.master.common.spring.mpbase.IdEntity;
import com.lysj.admin.master.common.spring.mpbase.MyEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter;

import javax.persistence.Entity;
import javax.persistence.Index;
import javax.persistence.Table;
import java.math.BigDecimal;
import java.util.Date;

/**
 * @author Created by zk on 2020-01-01 15:07
 * @description 费用明细
 */
@Data
@Entity
@EqualsAndHashCode(callSuper = true)
@TableName("lysj_company_cost_record")
@Table(name = "lysj_company_cost_record", indexes = {
        @Index(name = "idx_company_id", columnList = "companyId")})
public class CostRecord extends CompanyEntity {

    @Getter
    @AllArgsConstructor
    public enum OperationType implements EnumInterface {
        INCOME(1, "收入"),
        PAY(2, "支出");
        private Integer code;
        private String status;
    }

    @Getter
    @AllArgsConstructor
    public enum Operation implements EnumInterface {
        RECHARGE(1, "充值", OperationType.INCOME),
        COMMISSION(2, "服务费", OperationType.PAY),
        GRANT(3, "发放费用", OperationType.PAY),
        REFUND(4, "费用退还", OperationType.INCOME),//取消订单
        API_WITHDRAW(5, "API提现", OperationType.PAY),
        REWARD(6, "奖励", OperationType.INCOME);
        private Integer code;
        private String status;
        private OperationType type;
    }

    private String rechargeRecordId; //充值记录id
    private String commissionApplyId;//佣金发放记录id
    private String serviceProviderName;//服务商名
    private Integer operationType;//操作类型
    private BigDecimal amount;//金额
    private Integer operation;//操作 填充请使用本类方法 fillOperation
    private String remark;//备注

    private transient String operationTypeTxt;
    private transient String operationTxt;


    public void fillOperation(Operation operation) {
        this.operation = operation.code;
        this.operationType = operation.type.code;
    }
}
